package mao.sourcecode.threadlocal;

import java.util.concurrent.TimeUnit;

public class MyThreadLocal extends ThreadLocal<Integer> {
    @Override
    //这里需要加上synchronize否则产生并发访问问题。
    protected synchronized Integer initialValue() {
        int a = 8;
        a+=4;
        try {
            TimeUnit.MICROSECONDS.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        a-=4;
        return  Integer.valueOf(a);
    }
}
